/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.evote.monitoreo.mdb;

import com.evote.monitoreo.entity.Locacion;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;

/**
 *
 * @author Mendoza
 */
@MessageDriven(mappedName = "jms/MonitoreoNotificationBean", activationConfig =  {
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
    })
public class MonitoreoNotificationBean implements MessageListener {
    
    public MonitoreoNotificationBean() {
    }

    public void onMessage(Message message) {
        System.out.println("########## Meensage a la cola ############");
        try {
            Locacion locacion = (Locacion) ((ObjectMessage)message).getObject();
            System.out.println("Locacion id:" + locacion.getIdLocacion());
        } catch (JMSException ex) {
            Logger.getLogger(MonitoreoNotificationBean.class.getName()).log(Level.SEVERE, null, ex);
        }
        System.out.println("########## end message ############");
    }
    
}
